package EA.testproblems;
import EA.*;

/*
  De Jong function F3
  
  Created: 28. sept. 1999
  @version 1.0
  @author Rene Thomsen
*/

public class DeJongF3 extends NumericalProblem 
{

  // Easier way to build max and min
    private double[][] lmax = new double[0][2];
    private double[][] lmin = new double[0][2];

  public DeJongF3()
    {
      super();

      double[] optimas;

      name = "De Jong function F3";
      objectivefunction = new NumericalFitness(){
	      public double Fitness_calcFitness_inner(double[] realpos)
	      {
		  return ((int) realpos[0] + (int) realpos[1] + (int) realpos[2] +
  			  (int) realpos[3] + (int) realpos[4]);  
	      };
	  };

      dimensions = 5;
      ismaximization = false;
      optimumradius = 0.2;

      intervals = new Interval[5];
      intervals[0] = new Interval(-5.12, 5.12);
      intervals[1] = new Interval(-5.12, 5.12);
      intervals[2] = new Interval(-5.12, 5.12);
      intervals[3] = new Interval(-5.12, 5.12);
      intervals[4] = new Interval(-5.12, 5.12);
      
      // Set up known maximas
      knownmaxima = new NumericalOptimum[lmax.length];

      for (int i=0;i<lmax.length;i++) {
	optimas = new double[dimensions];
	optimas[0] = lmax[i][0];
	optimas[1] = lmax[i][1];
	optimas[2] = lmax[i][2];
	knownmaxima[i] = new NumericalOptimum(optimas, objectivefunction.calcFitness(optimas), true, false, i);
      }

      // Set up known minimas
      knownminima = new NumericalOptimum[lmin.length];

      for (int i=0;i<lmin.length;i++) {
	optimas = new double[dimensions];
	optimas[0] = lmin[i][0];
	optimas[1] = lmin[i][1];
	optimas[2] = lmin[i][2];
	knownminima[i] = new NumericalOptimum(optimas, objectivefunction.calcFitness(optimas), false, false, i);
      }
    }
}
